package D12_6z.反射andProperties_1;

import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.Properties;

public class Demo1 {
    public static void main(String[] args) throws Exception {
        write();
        Class<?> aClass = Class.forName(read());
        Method run = aClass.getDeclaredMethod("run");
        Object o = aClass.newInstance();
        run.invoke(o,null);
    }
    public static void write() throws IOException {
        Properties prop = new Properties();
        prop.setProperty("01","Y2019.M12_.D12_6z.反射andProperties_1.DemoClass");
        FileWriter writer = new FileWriter("prop.properties");
        prop.store(writer,"xxx");
        writer.close();
    }
    public static String read() throws Exception {
        Properties prop = new Properties();
        FileInputStream in = new FileInputStream("prop.properties");
        prop.load(in);
        in.close();
        return prop.getProperty("01");
    }
}
